package com.curluin.view;

import com.curluin.math.MyVector;

public class CameraRailCheckPoint {
	private static final String LOG_TAG = "CameraSetting";
	private MyVector ref;
	private MyVector rotation;
	private float zoomStep;
//	private CameraRailCheckPoint lastCheckPoint;
//	private CameraRailCheckPoint nextCheckPoint;
	
	public CameraRailCheckPoint(MyVector ref, MyVector rotation, float zoomStep) {
		super();
		this.ref = ref;
		this.rotation = rotation;
		this.zoomStep = zoomStep;
	}
	
//	public CameraRailCheckPoint(MyVector ref, MyVector rotation, float zoomStep, CameraRailCheckPoint lastCheckPoint, CameraRailCheckPoint nextCheckPoint) {
//		super();
//		this.ref = ref;
//		this.rotation = rotation;
//		this.zoomStep = zoomStep;
//		this.lastCheckPoint=lastCheckPoint;
//		this.nextCheckPoint=nextCheckPoint;
//	}

	/**
	 * @return the ref
	 */
	public MyVector getRef() {
		return ref;
	}

	public MyVector getDirection(MyVector actRef){
		MyVector direction = this.ref.subtract(actRef);
		direction.normalize();
		return direction;
	}
	
	public MyVector getNextRef(MyVector actRef, float distance){
		MyVector nextRef = actRef.add(getDirection(actRef).multiply(distance));
		return nextRef;
	}
	
	
	public boolean isPassed(CameraRailCheckPoint lastCheckPoint, MyVector actRef){
		float distLast2This= this.ref.subtract(lastCheckPoint.getRef()).getNorm();
		float distLast2Ref = lastCheckPoint.getRef().subtract(actRef).getNorm();
//		Log.w(LOG_TAG,"distance2Ref: "+distLast2Ref+" distance2Last: "+distLast2This);
		return distLast2Ref>distLast2This;
	}


	/**
	 * @return the rotation
	 */
	public MyVector getRotation() {
		return rotation;
	}


	/**
	 * @return the zoomStep
	 */
	public float getZoomStep() {
		return zoomStep;
	}
}
